var nodemailer = require("nodemailer");
var transporter = nodemailer.createTransport({
  service: "gmail",
  auth: {
    user: " youremail@gmail.com ",
    pass: " yourpassword ",
  },
});
var mailOptions = {
  from: " youremail@gmail.com ",
  //多个对象用,分隔
  to: " myfriend@yahoo.com ",
  subject: "Sending Email using Node.js",
  text: "That was easy!",
  //还可以发送html格式的文本
  //html: "<h1>HTML from email</h1>"
};
transporter.sendMail(mailOptions, function (error, info) {
  if (error) {
    console.log(error);
  } else {
    console.log("Email sent: " + info.response);
  }
});
